package modelo;

import java.sql.SQLException;

import javax.swing.JOptionPane;

import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class LoginDAO {
	boolean bandera;
	
	public boolean buscarPersona(LoginVO loginVO)
	{
		Conexion conex = new Conexion();
		try{
						
			PreparedStatement consulta = conex.getConnection().prepareStatement("SELECT * FROM usuarios where usuario = ? and password = ?");
			consulta.setString(1, loginVO.getUser());
			consulta.setString(2, loginVO.getPass());
			ResultSet res = consulta.executeQuery();
			if(res.next()){
				if(res.getString("usuario").equals(loginVO.getUser()) && res.getString("password").equals(loginVO.getPass())){
					bandera = true;
					System.out.println("Usuario Aceptado");
				}
			}
			else{
				System.out.println("Usuario Incorrecto : " + loginVO.getUser());
			}
			res.close();
			conex.desconectar();
			
			} catch (SQLException e){
					JOptionPane.showMessageDialog(null, "Error, no se conecto");
					System.out.println(e);
			}
		if(bandera){
			return true;
		}else{
			return false;
		}
	}
}
